package game.Engine.Entity;

import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.geom.Point2D;

import game.MainController;
import game.display.Animation;

/** Creates a circular reticle that helps aim
 * when the player casts a magic
 * 
 * @author DMEComputer
 *
 */

public class Mouse extends Entity 
{
   public Mouse(double x, double y, Animation gi) 
   {
      super(x, y, gi);
      z = new Double(Integer.MAX_VALUE);
      target = new Point2D.Double();
   }
   
   public void update(long timeElapsed) 
   {
      super.update(timeElapsed);
      Point p = MouseInfo.getPointerInfo().getLocation();
      setX((MainController.displayEngine.vw.getX() + p.x - MainController.getWindowX())/64D - .15625);
      setY((MainController.displayEngine.vw.getY() + p.y - MainController.getWindowY())/64D - .15625);
   }
   
   private Point2D.Double target;
   
   /** Returns the target, or reticle, that the player uses to aim their magic powers
    * 
    * @return the target, or reticle, that the player uses to aim their magic powers
    */
   
   public Point2D.Double getTarget() 
   {
      target.setLocation(getX() - .5 + .15625, getY() - .5 + .15625);
      return target;
   }

}
